<template>
    <div>
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="全部用户" name="first">
                <div style="margin:5px;display: inline-block;">
                    <span>手机号:</span>
                    <el-input style="width: 150px;" @keydown.enter.native="select" clearable placeholder="请输入手机号"
                        v-model="phone"></el-input>
                </div>&emsp;&emsp;
                <div style="margin:5px;display: inline-block;">
                    <span>昵称:</span>
                    <el-input style="width: 150px;" @keydown.enter.native="select" clearable placeholder="请输入昵称"
                        v-model="campus"></el-input>
                </div>&emsp;&emsp;
                <div style="margin:5px;display: inline-block;">
                    <span>邀请码:</span>
                    <el-input style="width: 150px;" @keydown.enter.native="select" clearable placeholder="请输入邀请码"
                        v-model="invitationCode"></el-input>
                </div>&emsp;&emsp;
                <div style="margin:5px;display: inline-block;">
                    <span>邀请人邀请码:</span>
                    <el-input style="width: 150px;" @keydown.enter.native="select" clearable placeholder="请输入邀请人邀请码"
                        v-model="inviterCode"></el-input>
                </div>&emsp;&emsp;
                <div style="margin:5px;display: inline-block;">
                    <span>开始时间：</span>
                    <el-date-picker style="width: 160px;margin-left: 10px;" v-model="startTime" align="right"
                        type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择开始时间">
                    </el-date-picker>&nbsp;&nbsp;&nbsp;
                </div>
                <div style="margin:5px;display: inline-block;">
                    <span>截止时间：</span>
                    <el-date-picker style="width: 160px;margin-left: 10px;" v-model="endTime" align="right" type="date"
                        format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择截止时间">
                    </el-date-picker>
                </div>
                <div style="display: inline-block;">
                    <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="select">查询
                    </el-button>
                    <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleans">重置
                    </el-button>
                    <el-button style='margin-left:15px;' size="mini" type="primary" icon="document"
                        @click="addUser">绑定陪诊师
                    </el-button>
                    <el-button style='margin-left:15px;' size="mini" type="warning" icon="document"
                        @click="exportBtn">导出Excel
                    </el-button>

                </div>
                <el-table v-loading="tableDataLoading" :data="tableData.list">
                    <el-table-column prop="userId" label="编号" width="80" fixed="left"></el-table-column>
                    <el-table-column fixed prop="userName" label="昵称" width="150">
                        <template slot-scope="scope">
                            <span style="color: #f56c6c;">{{ scope.row.userName ? scope.row.userName : '未绑定' }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="sex" label="性别">
                        <template slot-scope="scope">
                            <span v-if="scope.row.sex==1">男</span>
                            <span v-else-if="scope.row.sex==2">女</span>
                            <span v-else>未设置</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="图像">
                        <template slot-scope="scope">
                            <img v-if="scope.row.avatar==null" src="~@/assets/img/avatar.png" alt="" width="40"
                                height="40">
                            <img v-else :src="scope.row.avatar" alt="" width="40" height="40">
                        </template>
                    </el-table-column>
                    <el-table-column prop="phone" label="手机号">
                        <template slot-scope="scope">
                            <!-- <span style="color: #4f9dec;cursor: pointer;" @click="updates(scope.row)">
								{{ scope.row.phone ? scope.row.phone : '未绑定' }}
							</span> -->
                            <el-button size="mini" style="color: #4f9dec;background: #fff;border: none;padding: 0;"
                                type="primary" @click="updates(scope.row)">
                                {{ scope.row.phone ? scope.row.phone : '未绑定' }}
                            </el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="money" label="余额" width="100">
                        <template slot-scope="scope">
                            <span style="color: #4f9dec;background: #fff;border: none;">{{ scope.row.money ?
                                scope.row.money : '0.00' }}</span>
                        </template>
                    </el-table-column>

                    <el-table-column prop="creditScore" label="信用分"></el-table-column>
                    <el-table-column prop="invitationCode" label="邀请码"></el-table-column>
                    <el-table-column label="邀请人邀请码" width="150">
                        <template slot-scope="scope">
                            <!-- <span style="color: #4f9dec;cursor: pointer;"
								@click="updates2(scope.row)">{{ scope.row.inviterCode ? scope.row.inviterCode : '未绑定' }}</span> -->
                            <el-button size="mini" style="color: #4f9dec;background: #fff;border: none;padding: 0;"
                                type="primary" @click="updates2(scope.row)">
                                {{ scope.row.inviterCode ? scope.row.inviterCode : '未绑定' }}
                            </el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="zhiFuBaoName" label="是否实名">
                        <template slot-scope="scope">
                            <span v-if="scope.row.isAuthentication==1">是</span>
                            <span v-else>否</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="wxImg" label="收款二维码" width="150">
                        <template slot-scope="scope">
                            <div v-if="scope.row.wxImg == null || scope.row.wxImg == ''">
                                暂无收款二维码
                            </div>
                            <div v-else style="display:flex;flex-wrap: wrap;">
                                <div style="margin: 2px;">
                                    <el-popover placement="top-start" title="" trigger="hover">
                                        <img style="width: 50px; height: 50px" :src="scope.row.wxImg" alt=""
                                            slot="reference">
                                        <img style="width: 300px; height: 300px" :src="scope.row.wxImg" alt="">
                                    </el-popover>
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="zhiFuBaoName" label="支付宝名称" width="120">
                        <template slot-scope="scope">
                            <span>{{ scope.row.zhiFuBaoName ? scope.row.zhiFuBaoName : '未绑定' }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="zhiFuBao" label="支付宝账号" width="120">
                        <template slot-scope="scope">
                            <span>{{ scope.row.zhiFuBao ? scope.row.zhiFuBao : '未绑定' }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="rate" label="陪诊员佣金比例" width="150">
                        <template slot-scope="scope">
                            <span>{{scope.row.rate?scope.row.rate:'0'}}</span>
                            <el-button size="mini" style="color: #4f9dec;background: #fff;border: none;"
                                @click="xiugai(scope.row,'rate')">
                                修改</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="zhiRate" label="推广员佣金比例" width="150">
                        <template slot-scope="scope">
                            <span>{{scope.row.zhiRate?scope.row.zhiRate:'0'}}</span>
                            <el-button size="mini" style="color: #4f9dec;background: #fff;border: none;"
                                @click="xiugai(scope.row,'zhiRate')">修改</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="feiRate" label="代理商佣金比例" width="150">
                        <template slot-scope="scope">
                            <span>{{scope.row.feiRate?scope.row.feiRate:'0'}}</span>
                            <el-button size="mini" style="color: #4f9dec;background: #fff;border: none;"
                                @click="xiugai(scope.row,'feiRate')">修改</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="createTime" label="创建时间" width="160"></el-table-column>
                    <el-table-column prop="state " label="状态">
                        <template slot-scope="scope">
                            <el-switch v-model="scope.row.status" @change="change(scope.row.status,scope.row.userId)"
                                :active-value="openValue" :inactive-value="closeValue" active-color="#13ce66"
                                inactive-color="#ff4949">
                            </el-switch>
                        </template>
                    </el-table-column>
                    <el-table-column fixed="right" label="操作" width="120">
                        <template slot-scope="scope">
                            <el-button size="mini" type="primary" @click="updates(scope.row)">用户详情</el-button>
                            <el-button size="mini" type="warning" @click="issuePay(scope.row)">发放工资</el-button>
                            <el-button size="mini" type="danger" @click="deleteuser(scope.row)">解除绑定</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="text-align: center;margin-top: 10px;">
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :page-sizes="[10, 20, 30, 40, 50]" :page-size="limit" :current-page="page"
                        layout="total,sizes, prev, pager, next,jumper" :total="tableData.totalCount">
                    </el-pagination>
                </div>
            </el-tab-pane>
            <el-tab-pane label="我的申请" name="second">

                <el-table v-loading="tableDataLoading" :data="queryArr.list">
                    <el-table-column prop="userId" label="编号" width="80" fixed="left"></el-table-column>
                    <el-table-column fixed prop="name" label="姓名" width="150">
                        <template slot-scope="scope">
                            <span style="color: #f56c6c;">{{ scope.row.shiFuInfo ? scope.row.shiFuInfo.name : ''
                                }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="sex" label="性别">
                        <template slot-scope="scope">
                            <span v-if="scope.row.shiFuInfo.sex==1">男</span>
                            <span v-else-if="scope.row.shiFuInfo.sex==2">女</span>
                            <span v-else>未设置</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="age" label="年龄">
                        <template slot-scope="scope">
                            {{scope.row.shiFuInfo ? scope.row.shiFuInfo.age+'岁' : ''}}
                        </template>
                    </el-table-column>
                    <el-table-column label="头像">
                        <template slot-scope="scope">
                            <img v-if="scope.row.shiFuInfo.avatar==null" src="~@/assets/img/avatar.png" alt=""
                                width="40" height="40">
                            <img v-else :src="scope.row.shiFuInfo.avatar" alt="" width="40" height="40">
                        </template>
                    </el-table-column>
                    <el-table-column prop="phone" label="手机号" width="150">
                        <template slot-scope="scope">
                            {{ scope.row.shiFuInfo.phone ? scope.row.shiFuInfo.phone : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="serviceName" label="服务项目" width="250">
                        <template slot-scope="scope">
                            {{ scope.row.shiFuInfo.serviceName ? scope.row.shiFuInfo.serviceName : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="details" label="自我介绍" width="220">
                        <template slot-scope="scope">
                            {{ scope.row.shiFuInfo.details ? scope.row.shiFuInfo.details : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="status" label="状态" width="180">
                        <template slot-scope="scope">
                            <span style="color: #4f9dec;" v-if="scope.row.status==0">待接受</span>
                            <span style="color: #63b786;" v-else-if="scope.row.status==1">已接受</span>
                            <span style="color: #f56c6c;" v-else-if="scope.row.status==2">已拒绝</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="reason" label="拒绝原因" width="180">
                        <template slot-scope="scope">
                            {{ scope.row.status == 2 ? scope.row.reason : '无' }}
                        </template>
                    </el-table-column>

                    <el-table-column prop="reason" label="服务地区" width="180">
                        <template slot-scope="scope">
                            {{ `${scope.row.shiFuInfo.province}${scope.row.shiFuInfo.city}` }}
                        </template>
                    </el-table-column>
                </el-table>
                <div style="text-align: center;margin-top: 10px;">
                    <el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
                        :page-sizes="[10, 20, 30, 40, 50]" :page-size="limit2" :current-page="page2"
                        layout="total,sizes, prev, pager, next,jumper" :total="queryArr.totalCount">
                    </el-pagination>
                </div>
            </el-tab-pane>
            <el-tab-pane label="向我申请" name="three">
                <el-table v-loading="tableDataLoading" :data="queryArr.list">
                    <el-table-column prop="userId" label="编号" width="80" fixed="left"></el-table-column>
                    <el-table-column fixed prop="name" label="姓名" width="150">
                        <template slot-scope="scope">
                            <span style="color: #f56c6c;">{{ scope.row.shiFuInfo ? scope.row.shiFuInfo.name : ''
                                }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="sex" label="性别">
                        <template slot-scope="scope">
                            <span v-if="scope.row.shiFuInfo.sex==1">男</span>
                            <span v-else-if="scope.row.shiFuInfo.sex==2">女</span>
                            <span v-else>未设置</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="age" label="年龄">
                        <template slot-scope="scope">
                            {{scope.row.shiFuInfo ? scope.row.shiFuInfo.age+'岁' : ''}}
                        </template>
                    </el-table-column>
                    <el-table-column label="头像">
                        <template slot-scope="scope">
                            <img v-if="scope.row.shiFuInfo.avatar==null" src="~@/assets/img/avatar.png" alt=""
                                width="40" height="40">
                            <img v-else :src="scope.row.shiFuInfo.avatar" alt="" width="40" height="40">
                        </template>
                    </el-table-column>
                    <el-table-column prop="phone" label="手机号" width="150">
                        <template slot-scope="scope">
                            {{ scope.row.shiFuInfo.phone ? scope.row.shiFuInfo.phone : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="serviceName" label="服务项目" width="250">
                        <template slot-scope="scope">
                            {{ scope.row.shiFuInfo.serviceName ? scope.row.shiFuInfo.serviceName : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="details" label="自我介绍" width="220">
                        <template slot-scope="scope">
                            {{ scope.row.shiFuInfo.details ? scope.row.shiFuInfo.details : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="status" label="状态" width="180">
                        <template slot-scope="scope">
                            <span style="color: #4f9dec;" v-if="scope.row.status==0">待接受</span>
                            <span style="color: #63b786;" v-else-if="scope.row.status==1">已接受</span>
                            <span style="color: #f56c6c;" v-else-if="scope.row.status==2">已拒绝</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="reason" label="拒绝原因" width="180">
                        <template slot-scope="scope">
                            {{ scope.row.status == 2 ? scope.row.reason : '无' }}
                        </template>
                    </el-table-column>

                    <el-table-column prop="reason" label="服务地区" width="180">
                        <template slot-scope="scope">
                            {{ `${scope.row.shiFuInfo.province}${scope.row.shiFuInfo.city}` }}
                        </template>
                    </el-table-column>

                    <el-table-column fixed="right" label="操作" width="150">
                        <template slot-scope="scope" v-if="scope.row.status==0">
                            <el-button size="mini" type="primary" @click="jieshou(scope.row)">接受</el-button>
                            <el-button size="mini" type="warning" @click="jvjue(scope.row)">拒绝</el-button>
                        </template>
                    </el-table-column>


                </el-table>
                <div style="text-align: center;margin-top: 10px;">
                    <el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2"
                        :page-sizes="[10, 20, 30, 40, 50]" :page-size="limit2" :current-page="page2"
                        layout="total,sizes, prev, pager, next,jumper" :total="tableData.totalCount">
                    </el-pagination>
                </div>
            </el-tab-pane>



            <!-- 修改比例 -->
            <el-dialog title="修改佣金比例" :visible.sync="dialogFormVisible2" center>
                <div style="margin-bottom: 10px;">
                    <span style="width: 200px;display: inline-block;text-align: right;">佣金比例：</span>
                    <el-input style="width:50%;" v-model="proportion" type="number" :min="0" :controls="false"
                        placeholder="请输入佣金比例"></el-input>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible2 = false">取 消</el-button>
                    <el-button type="primary" @click="StairNoticeTo2()">确 定</el-button>
                </div>
            </el-dialog>

            <!-- 发放工资 -->
            <el-dialog title="发放工资" :visible.sync="dialogFormVisible4" center>
                <div style="margin-bottom: 10px;">
                    <div>
                        <span style="width: 200px;display: inline-block;text-align: right;">陪诊师余额：</span>
                        <el-input style="width:50%;" v-model="isPay.userPay" disabled type="number" :min="0"
                            :controls="false"></el-input>
                    </div>
                    <div style="display: flex;margin-top: 20px;">
                        <span style="width: 200px;display: inline-block;text-align: right;">微信收款二维码：</span>
                        <div v-if="!isPay.wxImg">暂无</div>
                        <img style="width: 200px; height: 250px" :src="isPay.wxImg" alt="" slot="reference" v-else>
                    </div>
                    <div style="margin-top: 20px;">
                        <span style="width: 200px;display: inline-block;text-align: right;">支付宝名称：</span>
                        <el-input style="width:50%;" v-model="isPay.zhiFuBaoName" disabled></el-input>
                    </div>
                    <div style="margin-top: 10px;">
                        <span style="width: 200px;display: inline-block;text-align: right;">支付宝账号：</span>
                        <el-input style="width:50%;" v-model="isPay.zhiFuBao" disabled></el-input>
                    </div>
                    <div style="color: red;font-size: 12px;margin-top: 20px;">*本系统只具备账单记录功能，转账过程中出现的债务纠纷，与本系统（公司）无关！
                    </div>
                </div>
                <div slot="footer" class="dialog-footer">
                    <!-- <el-button @click="dialogFormVisible4 = false">取 消</el-button> -->
                    <el-button type="primary" @click="issuePays()">工资已发放，请确定</el-button>
                </div>
            </el-dialog>


            <!-- 绑定陪诊师 -->
            <el-dialog title="绑定陪诊师" :visible.sync="dialogFormVisible3" center width="80%">
                <el-table v-loading="tableDataLoading" :data="tableData1.list">
                    <el-table-column prop="userId" label="编号" width="80" fixed="left"></el-table-column>
                    <el-table-column fixed prop="userName" label="昵称" width="150">
                        <template slot-scope="scope">
                            <span style="color: #f56c6c;">{{ scope.row.userName ? scope.row.userName : '未绑定' }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="sex" label="性别">
                        <template slot-scope="scope">
                            <span v-if="scope.row.sex==1">男</span>
                            <span v-else-if="scope.row.sex==2">女</span>
                            <span v-else>未设置</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="图像">
                        <template slot-scope="scope">
                            <img v-if="scope.row.avatar==null" src="~@/assets/img/avatar.png" alt="" width="40"
                                height="40">
                            <img v-else :src="scope.row.avatar" alt="" width="40" height="40">
                        </template>
                    </el-table-column>
                    <el-table-column prop="phone" label="手机号" />


                    <el-table-column prop="creditScore" label="信用分"></el-table-column>
                    <el-table-column prop="invitationCode" label="邀请码"></el-table-column>

                    <el-table-column prop="zhiFuBaoName" label="是否实名">
                        <template slot-scope="scope">
                            <span v-if="scope.row.isAuthentication==1">是</span>
                            <span v-else>否</span>
                        </template>
                    </el-table-column>


                    <el-table-column prop="createTime" label="创建时间" width="160"></el-table-column>

                    <el-table-column fixed="right" label="操作" width="120">
                        <template slot-scope="scope">

                            <el-button size="mini" :disabled="isCurrentUser(scope.row)" type="primary"
                                @click="addUserSelect(scope.row)">选择


                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="text-align: center;margin-top: 10px;">
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange1"
                        :page-sizes="[10, 20, 30, 40, 50]" :page-size="limit" :current-page="page1"
                        layout="total,sizes, prev, pager, next,jumper" :total="tableData1.totalCount">
                    </el-pagination>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible3 = false">取 消</el-button>
                    <el-button type="primary" @click="dialogFormVisible3 = false">确 定</el-button>
                </div>
            </el-dialog>


            <!-- 拒绝原因 -->
            <el-dialog title="填写拒绝原因" :visible.sync="dialogFormVisible5" center>
                <div style="margin-bottom: 10px;display: flex;justify-content: center;padding: 0 40px;">
                    <div style="width: 200px;text-align: right;margin-right: 10px;">拒绝原因:</div>
                    <el-input v-model="myDetails" style="width: 500px" type="textarea" placeholder="请输入拒绝原因"></el-input>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible5 = false">取 消</el-button>
                    <el-button type="primary" @click="jvjues()">确 定</el-button>
                </div>
            </el-dialog>




        </el-tabs>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                openValue: 1,
                closeValue: 2,
                state: 'false',
                limit: 10,
                limit1: 10,
                limit2: 10,
                page: 1,
                page1: 1,
                page2: 1,
                phone: '',
                nickNam: '',
                platform: 'all',
                isRelation: -1,
                isTuan: -1,
                value: '',
                member: -1,
                isPromotion: -1,
                isAgent: -1,
                payData: [],
                nickName: '',
                grade: '',
                name: '',
                isPay: {
                    wxImg: '',
                    userPay: '',
                    userId: undefined,
                    zhiFuBaoName: undefined,
                    zhiFuBao: undefined,
                },

                activeName: 'first',
                tableDataLoading: true,
                tableData: [],

                tableData1: [],

                platforms: [{
                    value: 'all',
                    label: '全部'
                }, {
                    value: 'wap',
                    label: '网站'
                }, {
                    value: 'app',
                    label: 'APP'
                }, {
                    value: 'weixin',
                    label: '微信公众号'
                },
                {
                    value: 'mp',
                    label: '微信小程序'
                }
                ],
                campus: '',
                homeData1: [],
                isAuthentication: 0,
                dialogFormVisible2: false,
                dialogFormVisible3: false,
                dialogFormVisible4: false,
                dialogFormVisible5: false,
                escortType: '',
                proportion: '',
                texts: '',
                userIdss: '',
                invitationCode: '',
                inviterCode: '',
                startTime: '',
                endTime: '',
                info: {
                    stockDate: this.getNowTime(), //日期
                },
                info2: {
                    stockDate2: this.getNowTime2(), //日期
                },
                userEntity: {},
                type: '',
                queryFrom: {
                    page: 1,
                    limit: 10,
                    shopId: sessionStorage.getItem('shopId'),
                    type: ""
                },



                myDetails: '',
                queryArr: {},
                form: {},
            }
        },
        computed: {
            userShopId: {
                get() { return this.$store.state.user.shopId },
                set(val) { this.$store.commit('user/updateShopId', val) }
            },
            userEntityList: {
                get() { return this.$store.state.user.userEntity },
                set(val) { this.$store.commit('user/userEntityList', val) }
            }
        },
        methods: {

            //填写拒绝原因
            jvjue(row) {
                this.dialogFormVisible5 = true;
                this.myDetails = '';
                this.form = row;
            },

            //拒绝绑定申请
            jvjues() {
                let data = {
                    status: 2,
                    id: this.form.id,
                    userId: this.form.userId,
                    shopId: this.form.shopId,
                    type: 2,
                    serviceIds: '',
                    reason: this.myDetails,
                }

                this.$http({
                    url: this.$http.adornUrl('admin/userShopBind/confirmBind'),
                    method: 'post',
                    data: this.$http.adornData(data)
                }).then(({ data }) => {
                    if (data && data.code === 0) {
                        this.dialogVisible5 = false
                        this.getList()
                        this.$message({
                            message: '拒绝成功',
                            type: 'success',
                            duration: 1500,
                            onClose: () => { }
                        })
                    }
                })

            },

            jieshou(row) {
                this.$confirm(`是否接受该师傅的绑定申请?`, '提示', {
                    confirmButtonText: '接受',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let data = {
                        status: 1,
                        id: row.id,
                        userId: row.userId,
                        shopId: row.shopId,
                        type: 2,
                        serviceIds: '',
                        reason: '',
                    }
                    this.$http({
                        url: this.$http.adornUrl(`admin/userShopBind/confirmBind`),
                        method: 'post',
                        data: this.$http.adornData(data)
                    }).then(data => {

                        if (data.data && data.data.code == 0) {
                            this.$message({
                                message: '已接受',
                                type: 'success',
                                duration: 1500,
                                onClose: () => {
                                    this.getList()
                                }
                            })
                        } else {
                            this.$message({
                                message: data.msg,
                                type: 'warning',
                                duration: 1500,
                                onClose: () => { }
                            })
                        }

                    })


                })
            },



            getNowTime2() {
                var now = new Date();
                var year = now.getFullYear(); //得到年份
                var month = now.getMonth(); //得到月份
                var date = now.getDate(); //得到日期
                month = month + 1;
                month = month.toString().padStart(2, "0");
                date = date.toString().padStart(2, "0");
                var defaultDate = `${year}-${month}-${date}`;
                return defaultDate;
                this.$set(this.info, "stockDate", defaultDate);
            },
            //处理默认选中当前日期
            getNowTime() {
                var now = new Date()
                var year = now.getFullYear() //得到年份
                var month = now.getMonth() - now.getMonth() //得到月份
                var date = now.getDate() - now.getDate() + 1 //得到日期
                month = month + 1
                month = month.toString().padStart(2, '0')
                date = date.toString().padStart(2, '0')
                var defaultDate = `${year}-${month}-${date}`
                return defaultDate
                this.$set(this.info, 'stockDate', defaultDate)
            },
            // 状态
            change(val, userId) {
                this.$http({
                    url: this.$http.adornUrl(`user/updateUserStatusByUserId?userId=${userId}`),
                    method: 'get',
                    data: this.$http.adornData({})
                }).then(({
                    data
                }) => {
                    this.$message({
                        message: '操作成功',
                        type: 'success',
                        duration: 1500,
                        onClose: () => {
                            this.dataSelect()
                        }
                    })
                })
            },
            // 详情跳转
            updates(row) {
                this.$router.push({
                    path: '/userDetail',
                    query: {
                        userId: row.userId
                    }
                })
            },
            // 详情跳转
            updates2(row) {
                // this.$router.push({
                // 	path: '/userDetail',
                // 	query: {
                // 		userId: row.superior
                // 	}
                // })
                if (row.inviterCode) {
                    this.$http({
                        url: this.$http.adornUrl('user/selectUserByInvitationCode'),
                        method: 'get',
                        params: this.$http.adornParams({
                            'invitationCode': row.inviterCode
                        })
                    }).then(({
                        data
                    }) => {
                        if (data.code == 0 && data.data) {
                            this.$router.push({
                                path: '/userDetail',
                                query: {
                                    userId: data.data.userId
                                }
                            })
                        } else if (data.code == 0 && data.data == null) {
                            this.$message({
                                message: '当前没有这个用户！',
                                type: 'warning',
                                duration: 1500,
                                onClose: () => { }
                            })
                        } else {
                            this.$message({
                                message: data.msg,
                                type: 'warning',
                                duration: 1500,
                                onClose: () => { }
                            })
                        }
                    })
                } else {
                    this.$message({
                        message: '未绑定邀请人',
                        type: 'warning',
                        duration: 1500,
                        onClose: () => { }
                    })
                }
            },
            handleClick(tab, event) {

                this.page = 1
                this.campus = ''
                this.invitationCode = ''
                this.inviterCode = ''
                this.phone = ''
                if (tab._props.label == '全部用户') {
                    this.isAuthentication = 0
                    this.isPromotion = -1
                    this.isAgent = -1
                    this.escortType = ''
                    this.dataSelect()
                }
                if (tab._props.name == 'second') {
                    this.page2 = 1
                    this.limit2 = 10
                    this.type = 1
                    this.getList()
                }
                if (tab._props.name == 'three') {
                    this.page2 = 1
                    this.limit2 = 10
                    this.type = 2
                    this.getList()
                }

            },


            //查询绑定列表

            getList() {
                this.queryFrom.type = this.type
                this.$http({
                    url: this.$http.adornUrl(`admin/userShopBind/getShiFuBindInfo`),
                    method: 'get',
                    params: this.$http.adornParams(this.queryFrom)
                }).then(it => {
                    if (it.data.code == 0) {
                        this.queryArr = it.data.data
                    }

                })
            },




            handleSizeChange(val) {
                this.limit = val
                this.dataSelect()
            },
            handleSizeChange1(val) {
                this.limit1 = val
                this.getAddUserList()
            },
            handleSizeChange2(val) {
                this.limit2 = val
                this.getList()
            },
            handleCurrentChange(val) {
                this.page = val
                this.dataSelect()
            },

            handleCurrentChange1(val) {
                this.page1 = val
                this.getAddUserList()
            },
            handleCurrentChange2(val) {
                this.page2 = val
                this.getList()
            },
            // 查询
            select() {
                this.page = 1
                this.dataSelect()
            },
            select2() {
                this.paySelect()
            },
            // 重置
            cleans() {
                this.page = 1
                this.campus = ''
                this.phone = ''
                this.invitationCode = ''
                this.inviterCode = ''
                this.startTime = ''
                this.endTime = ''
                this.dataSelect()
            },
            //解绑陪诊师
            deleteuser(row) {
                let delid = row.userId


                this.$http({
                    url: this.$http.adornUrl(`userCertification/getUserCertification`),
                    method: 'get',
                    params: this.$http.adornParams({
                        userId: delid
                    })
                }).then(it => {
                    console.log(it.data.data.serviceIds);

                })



                if (delid) {
                    this.$http({
                        url: this.$http.adornUrl(`user/${delid}`),
                        method: 'get',
                        params: this.$http.adornParams({
                            serviceId: ''
                        })
                    }).then(({
                        data
                    }) => {
                        const { money } = data.data
                        if (money > 0) {
                            this.$message({
                                message: '当前用户有余额，不能解除绑定！',
                                type: 'warning',
                                duration: 1500,
                                onClose: () => { }
                            })
                            return
                        } else {
                            this.$confirm(`确定解除绑定?`, '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                this.$http({
                                    url: this.$http.adornUrl(`user/unbindingShop?userId=${delid}`),
                                    method: 'post',
                                    data: this.$http.adornData({

                                    })
                                }).then(({
                                    data
                                }) => {
                                    if (data.code == 0) {
                                        this.$message({
                                            message: '解除绑定成功',
                                            type: 'success',
                                            duration: 1500,
                                            onClose: () => {
                                                this.dataSelect()
                                            }
                                        })
                                    } else {
                                        this.$message({
                                            message: data.msg,
                                            type: 'warning',
                                            duration: 1500,
                                            onClose: () => { }
                                        })
                                    }
                                })
                            })
                        }

                    })

                }

            },

            // 发放工资
            issuePay(row) {
                this.dialogFormVisible4 = true
                const { money, wxImg, userId, zhiFuBaoName, zhiFuBao } = row
                this.isPay.userPay = money
                this.isPay.wxImg = wxImg
                this.isPay.userId = userId
                this.isPay.zhiFuBaoName = zhiFuBaoName
                this.isPay.zhiFuBao = zhiFuBao
            },
            issuePays() {
                const { userPay, userId } = this.isPay

                // if (!wxImg) {
                //     this.$message({
                //         message: '请先添加收款二维码',
                //         type: 'warning',
                //         duration: 3000,
                //         onClose: () => { }
                //     })

                // } else {



                // }

                this.$confirm('是否确认已转账，确认后将结算陪诊师余额！！', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$http({
                        url: this.$http.adornUrl(`/user/addCannotMoney/${userId}/${userPay}/3`),
                        method: 'post',
                        data: this.$http.adornData({})
                    }).then(({ data }) => {
                        if (data.code == 0) {
                            this.$message({
                                message: '操作成功',
                                type: 'success',
                                duration: 2000,
                                onClose: () => {
                                    this.dialogFormVisible4 = false
                                    this.dataSelect()
                                }
                            })
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });

            },



            // 获取社区数据列表
            homeSelect() {
                this.tableDataLoading = true
                this.$http({
                    url: this.$http.adornUrl('helpCampus/selectCampusList'),
                    method: 'get',
                    params: this.$http.adornParams({
                        // 'page':this.page,
                        // 'limit':this.limit,
                        // 'content':this.content
                    })
                }).then(({
                    data
                }) => {
                    this.tableDataLoading = false
                    let returnData = data.data;
                    this.homeData1 = returnData
                })
            },
            // 筛选信息
            animeDat2(state) {
                this.dataSelect()
            },
            // 获取数据列表
            dataSelect() {
                this.tableDataLoading = true


                this.$http({
                    url: this.$http.adornUrl('user/selectUserList'),
                    method: 'get',
                    params: this.$http.adornParams({
                        'page': this.page,
                        'limit': this.limit,
                        'isPromotion': this.isPromotion,
                        'phone': this.phone,
                        'userName': this.campus,
                        'isAuthentication': this.isAuthentication,
                        'isAgent': this.isAgent,
                        'invitationCode': this.invitationCode,
                        'inviterCode': this.inviterCode,
                        'startTime': this.startTime,
                        'endTime': this.endTime,
                        'escortType': this.escortType,
                        'shopId': sessionStorage.getItem('shopId')
                    })
                }).then(({
                    data
                }) => {
                    this.tableDataLoading = false
                    let returnData = data.data
                    this.tableData = returnData
                })
            },

            // 绑定陪诊师傅
            addUser() {
                this.dialogFormVisible3 = true
                this.getAddUserList()
            },
            getAddUserList() {
                this.tableDataLoading = true
                this.$http({
                    url: this.$http.adornUrl('user/selectUserList'),
                    method: 'get',
                    params: this.$http.adornParams({
                        'page': this.page1,
                        'limit': this.limit1,
                        'shopId': 0,
                        'isAuthentication': 2,
                    })
                }).then(({
                    data
                }) => {
                    this.tableDataLoading = false
                    let returnData = data.data
                    this.tableData1 = returnData
                })
            },
            // 选择陪诊师傅
            addUserSelect(row) {


                this.$confirm('是否确认申请绑定该陪诊师', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$http({
                        url: this.$http.adornUrl('admin/userShopBind/bindShop'),
                        method: 'post',
                        data: this.$http.adornData({
                            status: 0,
                            userId: row.userId,
                            shopId: sessionStorage.getItem('shopId'),
                            type: 1,
                            serviceIds: '',
                            reason: "",
                        })
                    }).then(({
                        data
                    }) => {
                        if (data.code == 0) {
                            this.$message({
                                message: '发送成功',
                                type: 'success',
                                duration: 1500,
                                onClose: () => {


                                }
                            })
                        } else {
                            this.$message({
                                message: data.msg,
                                type: 'warning',
                                duration: 1500,
                                onClose: () => {
                                }
                            })
                        }

                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });




            },



            xiugai(row, text) {
                if (text == 'rate') {
                    this.proportion = row.rate
                }
                if (text == 'zhiRate') {
                    this.proportion = row.zhiRate
                }
                if (text == 'feiRate') {
                    this.proportion = row.feiRate
                }
                this.texts = text
                this.userIdss = row.userId
                this.dialogFormVisible2 = true
            },
            StairNoticeTo2() {
                var datas = {}
                if (this.texts == 'rate') {
                    datas.rate = this.proportion
                }
                if (this.texts == 'zhiRate') {
                    datas.zhiRate = this.proportion
                }
                if (this.texts == 'feiRate') {
                    datas.feiRate = this.proportion
                }
                datas.userId = this.userIdss
                this.$http({
                    url: this.$http.adornUrl('user/updateUserByUserId'),
                    method: 'post',
                    data: this.$http.adornData(datas)
                }).then(({
                    data
                }) => {
                    console.log('data', data)
                    if (data.code == 0) {
                        this.$message({
                            message: '修改成功',
                            type: 'success',
                            duration: 1500,
                            onClose: () => {
                                this.dialogFormVisible2 = false
                                this.dataSelect()
                            }
                        })
                    } else {
                        this.$message({
                            message: data.msg,
                            type: 'error',
                            duration: 1500,
                            onClose: () => {
                            }
                        })
                    }

                })
            },
            // 取消陪诊师傅
            quxiaodates(row) {
                let delid = row.userId
                this.$confirm(`确定要取消陪诊师傅?`, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$http({
                        url: this.$http.adornUrl('user/updateCertification'),
                        method: 'post',
                        params: this.$http.adornParams({
                            'userId': delid
                        })
                    }).then(({
                        data
                    }) => {
                        if (data.code == 0) {
                            this.$message({
                                message: '操作成功',
                                type: 'success',
                                duration: 1500,
                                onClose: () => {
                                    this.dataSelect()
                                }
                            })
                        } else {
                            this.$message({
                                message: data.msg,
                                type: 'warning',
                                duration: 1500,
                                onClose: () => { }
                            })
                        }
                    })
                })
            },
            // 导出
            exportBtn() {
                // if (this.endTime == '') {
                // 	this.endTime = this.info.stockDate
                // }
                // if (this.startTime == '') {
                // 	this.startTime = this.info2.stockDate2
                // }
                // var endTime = this.endTime
                // if (this.endTime != '') {
                // 	endTime = this.endTime + " 23:59:59"
                // }
                this.$http({
                    url: this.$http.adornUrl('user/userExportExcel'),
                    method: 'get',
                    responseType: 'blob',
                    params: this.$http.adornParams({
                        // 'page': page,
                        // 'size': this.size,
                        'isPromotion': this.isPromotion,
                        'phone': this.phone,
                        'userName': this.campus,
                        'isAuthentication': this.isAuthentication,
                        'isAgent': this.isAgent,
                        'invitationCode': this.invitationCode,
                        'inviterCode': this.inviterCode,
                        'startTime': this.startTime,
                        'endTime': this.endTime,
                    })
                }).then(({
                    data
                }) => {
                    let blob = new Blob([data], {
                        type: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
                    })
                    if (window.navigator.msSaveOrOpenBlob) {
                        navigator.msSaveBlob(blob)
                    } else {
                        let url = window.URL.createObjectURL(blob)
                        let elink = document.createElement('a')
                        elink.download = '用户列表.xlsx'
                        elink.style.display = 'none'
                        elink.href = url
                        document.body.appendChild(elink)
                        elink.click()
                        document.body.removeChild(elink)
                    }
                })
            },


            isCurrentUser(row) {

                if (row.userId == this.userEntity.userId) {
                    return true
                } else {
                    return false
                }
            }

        },
        created() {

            this.userEntity = JSON.parse(sessionStorage.getItem('userEntityList'))


        },
        mounted() {
            // this.homeSelect()
            this.dataSelect()

        }
    }
</script>

<style scoped="scoped">
    .el-button+.el-button {
        margin-left: 0 !important;
        margin-top: 5px !important;
    }
</style>